package com.jhhc.StormSurgeForecast.AstronomicalTide.ServiceImpl;

import com.jhhc.StormSurgeForecast.AstronomicalTide.Dao.BDMS_CALCULATESCHEME_M1Mapper;
import com.jhhc.StormSurgeForecast.AstronomicalTide.Pojo.BDMS_CALCULATESCHEME_M1;
import com.jhhc.StormSurgeForecast.AstronomicalTide.Pojo.TyphoonBO.TyphoonCschemeInfo;
import com.jhhc.StormSurgeForecast.AstronomicalTide.Service.BDMS_CALCULATESCHEME_MService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("BDMS_CALCULATESCHEME_MService")
public class BDMS_CALCULATESCHEME_M1ServiceImpl implements BDMS_CALCULATESCHEME_MService {

    @Resource
    private BDMS_CALCULATESCHEME_M1Mapper bdms_calculatescheme_m1Mapper;
    @Value("${datasourceType}")
    String datasourceType;

    @Override
    public BDMS_CALCULATESCHEME_M1 selcalSchemeId(String calSchemeId) {
        return bdms_calculatescheme_m1Mapper.selcalSchemeId(calSchemeId);
    }

    @Override
    public BDMS_CALCULATESCHEME_M1 selectNewOneByModel(String modelId) {
         return bdms_calculatescheme_m1Mapper.selectNewOneByModel(modelId);
    }

    @Override
    public BDMS_CALCULATESCHEME_M1 selectNewOneByModelMySql(String modelId, String startTime, String endTime) {
        return bdms_calculatescheme_m1Mapper.selectNewOneByModelMySql(modelId,startTime,endTime);
    }

//    @Override
//    public BDMS_CALCULATESCHEME_M1 selectNewOneByModel(String modelId,String startTime,String endTime) {
//        if ("mysql".equals(datasourceType)){
//            return bdms_calculatescheme_m1Mapper.selectNewOneByModelMySql(modelId,startTime,endTime);
//        }else if ("sqlserver".equals(datasourceType)){
//            return bdms_calculatescheme_m1Mapper.selectNewOneByModel(modelId);
//        }
//        return null;
//    }

    @Override
    public BDMS_CALCULATESCHEME_M1 selectShcemeByCalID(String calSchemeId) {
        return bdms_calculatescheme_m1Mapper.selectShcemeByCalID(calSchemeId);
    }

    @Override
    public List<BDMS_CALCULATESCHEME_M1> selectShcemeByCalIds(List<String> calSchemeIds) {
        return bdms_calculatescheme_m1Mapper.selectShcemeByCalIds(calSchemeIds);
    }

    @Override
    public List<BDMS_CALCULATESCHEME_M1> selectShcemeFlagByCalID(String calSchemeId) {
        return bdms_calculatescheme_m1Mapper.selectShcemeFlagByCalID(calSchemeId);
    }

    @Override
    public List<BDMS_CALCULATESCHEME_M1> selectShcemeByPidCalID(Integer project, String calSchemeId) {
        return bdms_calculatescheme_m1Mapper.selectShcemeByPidCalID(project, calSchemeId);
    }

    @Override
    public int updateGen(String cschemeid,int gen) {
        return bdms_calculatescheme_m1Mapper.updateGen(cschemeid,gen);
    }

    @Override
    public List<BDMS_CALCULATESCHEME_M1> selectShcemeByPidDate(Integer projectId, String tfId, String startTime, String endTime, String IsPublished,String status,String forecaster,String path,String flag,String modelId) {
        if ("mysql".equals(datasourceType)){
            //打印每个参数
//            System.out.println(projectId);
//            System.out.println(tfId);
//            System.out.println(startTime);
//            System.out.println(endTime);
//            System.out.println(IsPublished);
//            System.out.println(status);
//            System.out.println(forecaster);
//            System.out.println(path);
//            System.out.println(flag);
//            System.out.println(modelId);
            return bdms_calculatescheme_m1Mapper.selectShcemeByPidDate(projectId, tfId, startTime, endTime, IsPublished,status,forecaster,path,flag,modelId);
        }else if ("sqlserver".equals(datasourceType)){
            return bdms_calculatescheme_m1Mapper.selectShcemeByPidDateSqlserver(projectId, tfId, startTime, endTime, IsPublished,status,forecaster,path,flag,modelId);
        }
        return null;
    }

    @Override
    public int saveCalSchemeInfo(BDMS_CALCULATESCHEME_M1 bdms_calculatescheme_m) {
        return bdms_calculatescheme_m1Mapper.saveCalSchemeInfo(bdms_calculatescheme_m);
    }

    @Override
    public int insertBdmsCalculateschemeM(BDMS_CALCULATESCHEME_M1 bdms_calculatescheme_m) {
        return bdms_calculatescheme_m1Mapper.insertBdmsCalculateschemeM(bdms_calculatescheme_m);
    }

    @Override
    public BDMS_CALCULATESCHEME_M1 selectByNewOne() {
        if ("mysql".equals(datasourceType)){
            return bdms_calculatescheme_m1Mapper.selectByNewOneMySql();
        }else if ("sqlserver".equals(datasourceType)){
            return bdms_calculatescheme_m1Mapper.selectByNewOne();
        }
       return null;
    }

    @Override
    public int deleteCalById(List<String>  calSchemeId) {
        return bdms_calculatescheme_m1Mapper.deleteCalById(calSchemeId);
    }

    @Override
    public BDMS_CALCULATESCHEME_M1 selectNewOneByPid(Integer pid) {
        if ("mysql".equals(datasourceType)){
            return bdms_calculatescheme_m1Mapper.selectNewOneByPidMysql(pid);
        }else if ("sqlserver".equals(datasourceType)){
            return bdms_calculatescheme_m1Mapper.selectNewOneByPid(pid);
        }
       return null;
    }

    @Override
    public void updataByCschemeid(int flag,String cschemeid) {
        bdms_calculatescheme_m1Mapper.updataByCschemeid(flag,cschemeid);
    }

    @Override
    public List<TyphoonCschemeInfo> getRealPaths(int projectId) {
        return bdms_calculatescheme_m1Mapper.getRealPaths(projectId);
    }

    @Override
    public BDMS_CALCULATESCHEME_M1 selectNewOneByPidModel(int projectId, String tfId, String modelId,String area) {
        return bdms_calculatescheme_m1Mapper.selectNewOneByPidModel(projectId, tfId, modelId, area);
    }

    @Override
    public int updateStatus(String state, String cschemeId) {
        return bdms_calculatescheme_m1Mapper.updateStatus(state, cschemeId);
    }

    @Override
    public int updateArea(String area, String cschemeId) {
        return bdms_calculatescheme_m1Mapper.updateArea(area, cschemeId);
    }

    @Override
    public int deleteByCschemeId(String cschemeId) {
        return bdms_calculatescheme_m1Mapper.deleteByCschemeId(cschemeId);
    }

    @Override
    public List<String> selectCschemeId(String startTime, String endTime, String projectId) {
        return bdms_calculatescheme_m1Mapper.selectCschemeId(startTime,endTime,projectId);
    }
}
